#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
const int SIZE = 31;
int lineBase[SIZE];
inline void Init() {
    memset(lineBase, 0, sizeof(lineBase));
}
void Insert(int ask) {
    for (int j=SIZE-1; j>=0; --j) {
        int t = (1<<j);
        if (!(ask&t)) continue;
        if (lineBase[j]&t) ask^=lineBase[j];
        else {
            for (int i=0; i<j; ++i) if (ask&(1<<i)) ask ^= lineBase[i];
            lineBase[j] = ask;
            for (int i=j+1; i<SIZE; ++i) if (lineBase[i]&(1<<j)) lineBase[i] ^= ask;
            return;
        }
    }
}
bool isOK(int a) {
    int res = a;
    for (int i=SIZE-1; i>=0; --i) {
        if (res&(1<<i)) res ^= lineBase[i];
    }
    return !res;
}
void show() {
    for (int i=0; i<SIZE; ++i) {
        for (int j=SIZE-1; j>=0; --j) printf("%d ", (bool)(lineBase[i]&(1<<j)));
        printf("\n");
    }
}

int main(int argc, char** argv) {
#ifdef hai
    //freopen("in.txt", "r", stdin);
#endif
    int n,q;
    while (~scanf("%d", &n)) {
        Init();
        int t;
        for (int i=0; i<n; ++i) {
            scanf("%d", &t);
            Insert(t);
        }
        show();
        scanf("%d", &q);
        int a,b;
        for (int i=0; i<q; ++i) {
            scanf("%d %d", &a, &b);
            a ^= b;
            if (isOK(a)) printf("YES\n");
            else printf("NO\n");
        }
    }
    return 0;
}
